<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><? echo $title ?></title>
<? require("lib.php"); ?>
</head>
<body>
  <div class="content-box"><!-- Start Content Box -->
    <div class="content-box-header">
      <h3><? echo $title ?></h3>
      <div class="clear"></div>
    </div> <!-- End .content-box-header -->
    <div class="content-box-content">
<?
  switch ($do){
    case "add":
    add();
    break;
    case "update":
    update($info);
    break;
    case "delete":
    delete($id);
    break;
    case "flip": flip($id); break;
    case "featured": flip($id,'is_featured'); break;
    default:
    show_info($info);
  }
 ?>
<? function show_boxes($result){
	global $url, $page, $pages, $cateid, $cate, $s, $lang, $filter, $option_module;

	$str='<table width="99%" class="mlist class"><tr>';  // 搜索
	$str.='<td><form action="'.$url.'.php" method="get"><input placeholder="'.ROOT_SEARCH_BY_PRODUCT_NAME_AND_SKU.'" name="s" class="g" value="'.$s.'" /> &nbsp; <input type="submit" class="button_blue" value=" '.ROOT_SEARCH.' " /></form></td></tr></table>';
	$str='<table width="99%" cellspacing="0" class="mlist"><tr class="th"><td><strong>#</strong></td><td><strong>'.ROOT_NAME.'</strong></td><td><strong>'.ROOT_SKU.'</strong></td><td><strong>'.ROOT_PRICE.'</strong></td><td><strong>'.ROOT_STOCK.'</strong></td><td><strong>'.ROOT_SAFETY_STOCK.'</strong></td></tr>';
	$count=1;

  foreach($result as $row)
	{
		$id=decode($row['id']);
		$enable=$row['is_enabled']?ROOT_OFF_SHELF:ROOT_ON_SHELF;
		$featured=$row['is_featured']?ROOT_OFF_RECOMMAND:ROOT_ON_RECOMMAND;
    $class='';
    if($row['safety_stock']>=$row['stock']) $class=' class="row_tip" ';
    if($row['stock']<1) $class=' class="row_warning" ';
		$str.="<tr ".$class."><td>".$id.".</td><td>".decode($row['name_'.$lang])."</td><td>".$row['sku']."</td><td>".$row['price']."</td><td>".$row['stock']."</td><td>".$row['safety_stock']."</td></tr>";
		$count++;
	}
	$str.= "</table>";
	echo $str;
	if($count==1) echo "<br>".ROOT_NO_DATA."!";
	echo echo_page($page, $pages, $url.'-'.$cateid.'-p');
       } ?>
   <br class="clear" />
	</div> <!-- End .content-box-content -->
               <br class="clear" />
</div><!-- End .content-box -->
</body>
</html>
